package com.tanhua.dubbo.server.api;

import com.tanhua.dubbo.server.pojo.Option;
import com.tanhua.dubbo.server.pojo.Question;
import com.tanhua.dubbo.server.pojo.Soul;
import org.bson.types.ObjectId;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class TsetShuJu {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private QuestionApi questionApi;
    @Test
    public void testSoul(){
        Soul soul = new Soul();
        soul.setId(ObjectId.get());
        soul.setUserId(1l);
        soul.setName("高级灵魂题");
        soul.setCover("https://tanhua-dev.oss-cn-zhangjiakou.aliyuncs.com/images/test_soul/qn_cover_01.png");
        soul.setLevel("高级");
        soul.setStar(5);
        Query query = Query.query(Criteria.where("type").is(1));
        List<Question> questions = mongoTemplate.find(query, Question.class);
        List<String> list = new ArrayList<>();
        for (Question question : questions) {
            list.add(question.getId());
        }
        soul.setQuestionIds(list);
        soul.setIsLock(1);
//        soul.setReportId();

        mongoTemplate.save(soul);
    }

    @Test
    public void test1(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("你何时感觉最好？");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("早晨");
        option.setScore(2);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("下午及傍晚");
        option1.setScore(4);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("夜里");
        option2.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test2(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("你走路时是");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("大步地快走");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("小步地块走");
        option1.setScore(4);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("不快，仰着头面对着世界");
        option2.setScore(7);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("不快，低着头");
        option3.setScore(2);

        Option option4 = new Option();
        option4.setId(String.valueOf(ObjectId.get()));
        option4.setOption("很慢");
        option4.setScore(1);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test3(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("和人说话时");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("手臂交叠站着");
        option.setScore(4);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("双手紧握着");
        option1.setScore(2);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("一只手或两只手放在臀部");
        option2.setScore(5);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("碰着或推着与你说话的人");
        option3.setScore(7);

        Option option4 = new Option();
        option4.setId(String.valueOf(ObjectId.get()));
        option4.setOption("玩着你的耳朵，摸着你的下巴或用手整理头发");
        option4.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test4(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("坐着休息时");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("两膝盖并拢");
        option.setScore(4);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("两腿交叉");
        option1.setScore(6);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("两腿伸直");
        option2.setScore(2);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("一腿蜷在身下");
        option3.setScore(1);

//        Option option4 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("玩着你的耳朵，摸着你的下巴或用手整理头发");
//        option4.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
//        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test5(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("碰到你感到发笑的事时，你的反应是");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("一个欣赏的大笑");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("笑着，但不大声");
        option1.setScore(4);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("轻声地笑");
        option2.setScore(3);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("羞怯的微笑");
        option3.setScore(5);

//        Option option4 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("玩着你的耳朵，摸着你的下巴或用手整理头发");
//        option4.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
//        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test6(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("当你去一个派对或社交场合时");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("很大声地入场以引起注意");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("安静地入场，找你认识的人");
        option1.setScore(4);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("非常安静地入场，尽量保持不被注意");
        option2.setScore(2);

//        Option option3 = new Option();
//        option3.setId(String.valueOf(ObjectId.get()));
//        option3.setOption("羞怯的微笑");
//        option3.setScore(5);

//        Option option4 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("玩着你的耳朵，摸着你的下巴或用手整理头发");
//        option4.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);
//        list.add(option3);
//        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test7(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("当你非常专心工作时，有人打断你，你会");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("欢迎他");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("感到非常愤怒");
        option1.setScore(2);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("在上述两极端之间");
        option2.setScore(4);

//        Option option3 = new Option();
//        option3.setId(String.valueOf(ObjectId.get()));
//        option3.setOption("羞怯的微笑");
//        option3.setScore(5);

//        Option option4 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("玩着你的耳朵，摸着你的下巴或用手整理头发");
//        option4.setScore(6);

        list.add(option);
        list.add(option1);
        list.add(option2);
//        list.add(option3);
//        list.add(option4);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test8(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("下列颜色中，你最喜欢哪一种颜色？");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("红或橘色");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("黑色");
        option1.setScore(7);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("黄色或浅蓝色");
        option2.setScore(5);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("绿色");
        option3.setScore(4);

        Option option4 = new Option();
        option4.setId(String.valueOf(ObjectId.get()));
        option4.setOption("深蓝色或紫色");
        option4.setScore(3);

        Option option5 = new Option();
        option5.setId(String.valueOf(ObjectId.get()));
        option5.setOption("白色");
        option5.setScore(2);

        Option option6 = new Option();
        option6.setId(String.valueOf(ObjectId.get()));
        option6.setOption("棕色或灰色");
        option6.setScore(1);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
        list.add(option4);
        list.add(option5);
        list.add(option6);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test9(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("临入睡的前几分钟，你在床上的姿势是");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("仰躺，伸直");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("俯躺，伸直");
        option1.setScore(7);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("侧躺，微蜷");
        option2.setScore(5);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("头睡在一手臂上");
        option3.setScore(4);

        Option option4 = new Option();
        option4.setId(String.valueOf(ObjectId.get()));
        option4.setOption("被子盖过头");
        option4.setScore(3);

//        Option option5 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("白色");
//        option4.setScore(2);
//
//        Option option6 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("棕色或灰色");
//        option4.setScore(1);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
        list.add(option4);
//        list.add(option5);
//        list.add(option6);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void test10(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("你经常梦到自己在");
        question.setType(1);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("落下");
        option.setScore(4);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("打架或挣扎");
        option1.setScore(2);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("找东西或人");
        option2.setScore(3);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("飞或漂浮");
        option3.setScore(5);

        Option option4 = new Option();
        option4.setId(String.valueOf(ObjectId.get()));
        option4.setOption("你平常不做梦");
        option4.setScore(6);

        Option option5 = new Option();
        option5.setId(String.valueOf(ObjectId.get()));
        option5.setOption("你的梦都是愉快的");
        option5.setScore(1);
//
//        Option option6 = new Option();
//        option4.setId(String.valueOf(ObjectId.get()));
//        option4.setOption("棕色或灰色");
//        option4.setScore(1);

        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);
        list.add(option4);
        list.add(option5);
//        list.add(option6);

        question.setOptions(list);

        mongoTemplate.save(question);
    }

    @Test
    public void testType2(){
        Question question = new Question();
        question.setId(String.valueOf(ObjectId.get()));
        question.setQuestion("我不会想别人为什么会这样做");
        question.setType(3);

        List<Option> list = new ArrayList<>();

        Option option = new Option();
        option.setId(String.valueOf(ObjectId.get()));
        option.setOption("不准确");
        option.setScore(6);

        Option option1 = new Option();
        option1.setId(String.valueOf(ObjectId.get()));
        option1.setOption("中性");
        option1.setScore(5);

        Option option2 = new Option();
        option2.setId(String.valueOf(ObjectId.get()));
        option2.setOption("一般准确");
        option2.setScore(2);

        Option option3 = new Option();
        option3.setId(String.valueOf(ObjectId.get()));
        option3.setOption("准确");
        option3.setScore(1);


        list.add(option);
        list.add(option1);
        list.add(option2);
        list.add(option3);

        question.setOptions(list);

        mongoTemplate.save(question);
    }
}
